// 封装用户相关操作
// es6按需导入导出
import ajaxs from '../utils/request.js'
// import { getUser } from '../utils/storage.js'
// import { Form } from 'element-ui'
// 传入手机号验证码案例进行登录操作
export const userLogin = (mobile, code) => {
  return ajaxs({
    method: 'post',
    url: '/mp/v1_0/authorizations',
    data: {
      mobile: mobile,
      code: code
    }
  })
}
// 获取用户身份信息
export const getUserProfile = () => {
  // const userInfo = JSON.parse(localStorage.getItem('userInfo'))
  // const userInfo = getUser()
  // 请求接口，
  return ajaxs({
    method: 'GET',
    url: '/mp/v1_0/user/profile'
    // headers: {
    //   Authorization: `Bearer ${userInfo.token}`
    // }
    // 设置给到了request.js的请求拦截器
  })
}
// 修改用户信息
export const modUserProfile = (data) => {
  return ajaxs({
    method: 'PATCH',
    url: '/mp/v1_0/user/profile',
    data
  })
}
/**
 * 修改头像
 * @param {*} formData  是一个FormData格式的对象
 */
export const moduserImage = (formData) => {
  return ajaxs({
    method: 'PATCH',
    url: '/mp/v1_0/user/photo',
    data: formData
  })
}
